<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">

<title>价格维护</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	<%@ include file="/WEB-INF/jsp/common/header.jsp"%>
	<%@ include file="/WEB-INF/jsp/common/loadDiv.jsp"%>

	<script type="text/javascript">
		$(function() { 
			bindgrid(); 
		});
	</script>
	<script>
		function del(node) {
			$.ajax({
				type : "delete",
				url : 'sys/price/delete?priId=priId',
				//                dataType: "xml",				
				success : function(data) {
					$.messager.alert('消息', data);
					$('#add').window('close');
					bindgrid();
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$.messager.alert('消息', errorThrown);
				}
			});
		}

		function save() {
	        if (!$('#fm').form('validate')) {
	            return;
	        }
	       var model={ priId:$('#priId').textbox('getValue'),
	       priOrg:$('#priOrg').textbox('getValue'),
	       priOrgName:$('#priOrgName').textbox('getValue'),
	       priCustom:$('#priCustom').textbox('getValue'),
	       priCustomName:$('#priCustomName').textbox('getValue'),
	       priCountry:$('#priCountry').textbox('getValue'),
	       priCountryName:$('#priCountryName').textbox('getValue'),
	       priRegion:$('#priRegion').textbox('getValue'),
	       priRegionName:$('#priRegionName').textbox('getValue'),
	       priPrice:$('#priPrice').textbox('getValue'),
	       priLevel:$('#priLevel').textbox('getValue'),
	       priLevelName:$('#priLevelName').textbox('getValue'),
	       priMm:$('#priMm').textbox('getValue'),
	       priMmName:$('#priMmName').textbox('getValue'),
	       priCurrency:$('#priCurrency').textbox('getValue'),
	       priCurrencyName:$('#priCurrencyName').textbox('getValue'),
	       priFix:$('#priFix').textbox('getValue'),
	       priFixName:$('#priFixName').textbox('getValue'),
	       priCalcu:$('#priCalcu').textbox('getValue'),
	       priCalcuName:$('#priCalcuName').textbox('getValue'),
	       priStartTime:$('#priStartTime').textbox('getValue'),
	       priEndTime:$('#priEndTime').textbox('getValue'),
	       createTime:$('#createTime').textbox('getValue'),
	       createName:$('#createName').textbox('getValue'),
	       createId:$('#createId').textbox('getValue'),
	       updateId:$('#updateId').textbox('getValue'),
	       updateName:$('#updateName').textbox('getValue'),
	       updateTime:$('#updateTime').textbox('getValue'),
	       delFlag:$('#delFlag').textbox('getValue'),
	       status:$('#status').textbox('getValue'),
	       remark:$('#remark').textbox('getValue')
	       } ;
	       $.ajax({
            type: "post",
            dataType: "json",
            url: 'sys/price/save',
            data: JSON.stringify(model),
            contentType: "application/json",
            success: function (data) {
                if (data.code != 60200) {
                    $.messager.alert('消息', data.msg);
                } else {
                    $.messager.alert('消息', data.msg);
                    let dg = $('#dg');
                    dg.datagrid('enableFilter');
                    dg.datagrid('load');
                    $('#add').window('close');
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.alert('消息', errorThrown);
            }
       		})			
           
		}
		
		function editrow() {
			//编辑用户
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				$('#add').window('open');
				$('#fm').form('load',row);
				
			} else {
				$.messager.alert('消息', '请选中一个用户');
			}
		}
	</script>
	<script>
		function bindgrid() {
			$('#dg').datagrid(
					{
						title : '价格列表',
						url : "sys/price/selectList",
						iconCls : 'icon-application',
						width : getWidth(0.98),
						height : 400,
						nowrap : true,
						rownumbers : true,
						animate : false,
						collapsible : false,
			            clientPaging: false,
			            remoteFilter: true,
						singleSelect : true,
            			pagination: true,
						remoteSort : true,
						columns : [ [{
						 	field : 'priId',
							title : '产品价格id',
							sortable : true,
							hidden: true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priOrg',
							title : '销售组织编码',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priOrgName',
							title : '销售组织名称',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priCustom',
							title : '客户编码',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priCustomName',
							title : '客户名称',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priCountry',
							title : '国家编码',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priCountryName',
							title : '国家名称',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priRegion',
							title : '地区编码',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priRegionName',
							title : '地区名称',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priPrice',
							title : '价格',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priLevel',
							title : '客户级别编码',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priLevelName',
							title : '客户级别名称',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priMm',
							title : '物料编码',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priMmName',
							title : '物料名称',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priCurrency',
							title : '币种编码',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priCurrencyName',
							title : '币种名称',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priFix',
							title : '定价单位编码',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priFixName',
							title : '定价单位名称',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priCalcu',
							title : '计量单位编码',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priCalcuName',
							title : '计量单位名称',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priStartTime',
							title : '有效期起始时间',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'priEndTime',
							title : '有效期截至时间',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'createTime',
							title : 'create_time',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'createName',
							title : 'create_name',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'createId',
							title : 'create_id',
							sortable : true,
							hidden: true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'updateId',
							title : 'update_id',
							sortable : true,
							hidden: true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'updateName',
							title : 'update_name',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'updateTime',
							title : 'update_time',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'delFlag',
							title : 'del_flag',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'status',
							title : 'status',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}, {
						 	field : 'remark',
							title : 'remark',
							sortable : true,
							formatter : function(val, rec) {
								 return val ? unescape(val) : '';
							}
						}  ] ],
						toolbar : [{
									text : '增加',
									iconCls : 'icon-add',
									handler : function() { 
										$('#fm').form('clear');
										$('#add').window('open');									 
									}
								},
								'-',
								{
									text : '编辑',
									iconCls : 'icon-edit',
									handler : function() {
									    var row = $('#dg').datagrid('getSelected');
							            if (row){
							                $('#add').dialog('open').dialog('center').dialog('setTitle','');
							                $('#fm').form('load',row);
							                
							            }
									}
								},
								'-',
								{
									text : '删除',
									iconCls : 'icon-cancel',
									handler : function() { 
										var row = $('#dg').datagrid(
												'getSelected');
										if (row) {
											$.messager.confirm('提示', '确定要删除吗?', function(r) {
												if (r) {del(row);}
											});
										}
									}
								}],
						onLoadSuccess : function() {
						},
						onDblClickRow : function() {
							editrow();
						}
					});
					$('#dg').datagrid('enableFilter');
		} 
	</script>
	<style scoped="scoped">
.textbox {
	height: 20px;
	margin: 0;
	padding: 0 2px;
	box-sizing: content-box;
}

/*.table tr {
        height: 15px;
    }*/
</style> 
				<table id="dg"></table>
				
	
	<div id="add" class="easyui-window" closed="true" modal="true"
		title="用户信息" style="width: 500px; height: 450px; padding: 10px 20px">
		<form id="fm" class="ssec-form">
			<table class="table">
				<tr>
					<td>
						<div class="ssec-label">产品价格id：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priId" name="priId" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">销售组织编码：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priOrg" name="priOrg" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">销售组织名称：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priOrgName" name="priOrgName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">客户编码：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priCustom" name="priCustom" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">客户名称：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priCustomName" name="priCustomName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">国家编码：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priCountry" name="priCountry" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">国家名称：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priCountryName" name="priCountryName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">地区编码：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priRegion" name="priRegion" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">地区名称：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priRegionName" name="priRegionName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">价格：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priPrice" name="priPrice" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">客户级别编码：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priLevel" name="priLevel" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">客户级别名称：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priLevelName" name="priLevelName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">物料编码：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priMm" name="priMm" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">物料名称：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priMmName" name="priMmName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">币种编码：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priCurrency" name="priCurrency" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">币种名称：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priCurrencyName" name="priCurrencyName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">定价单位编码：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priFix" name="priFix" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">定价单位名称：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priFixName" name="priFixName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">计量单位编码：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priCalcu" name="priCalcu" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">计量单位名称：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priCalcuName" name="priCalcuName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">有效期起始时间：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priStartTime" name="priStartTime" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">有效期截至时间：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="priEndTime" name="priEndTime" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">create_time：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="createTime" name="createTime" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">create_name：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="createName" name="createName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">create_id：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="createId" name="createId" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">update_id：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="updateId" name="updateId" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">update_name：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="updateName" name="updateName" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">update_time：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="updateTime" name="updateTime" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">del_flag：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="delFlag" name="delFlag" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">status：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="status" name="status" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="ssec-label">remark：</div>
					</td>
					<td>
						<div class="ssec-text normal">
							<input id="remark" name="remark" class="easyui-textbox"
								data-options="required:true" />
						</div>
					</td>
				</tr>
			</table>
			<div style="padding: 5px; text-align: right;">
				<a class="easyui-linkbutton" onclick="save();" iconcls="icon-save">保存</a>
			</div>
		</form>
	</div>
</body>
</html>
